<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />

<?php
if(isset($_POST['submit'])){
    require_once 'model/san_pham.php';
    $md_sanpham=new san_pham();
    var_dump($_FILES["file"]);
    if(move_uploaded_file($_FILES['file']['tmp_name'],'../public/images/'.$_FILES['file']['name'])){
        $params=array(
            'name'=>$_POST['name'],
            'gia'=>$_POST['gia'],
            'mo_ta'=>$_POST['des'],
            'gioi_tinh'=>$_POST['gioitinh'],
            'chuan_loai'=>$_POST['loaiao'],
            'nhap_vao'=>$_POST['sl'],
            'id_khuyen_mai'=>$_POST['loaikhuyenmai'],
            'hinh_anh'=>$_FILES['file']['name'],
        );
        var_dump($md_sanpham->insert($params));
    }
}
?>

<form enctype="multipart/form-data" method="post">
    <table border="0">
        <tr>
            <td>Tên sản phẩn</td>
            <td><input type="text" name="name"></td>
        </tr>
        <tr>
            <td>Giá:</td><td> <input type="text" name="gia"></td>
        </tr>
         <tr>
            <td>Số Lượng: </td><td><input type="text" name="sl"></td>
        </tr>
        <tr>
            <td>Nam | Nữ: </td>
            <td>
                <select name="gioitinh">
                    <option value="1">Nam</option>
                    <option value="0">nữ</option>
                </select>
            </td>
    </tr>
    <tr>
        <td>Áo Thun | khoác: </td>
        <td>
            <select name="loaiao">
            <option value="1"> Áo thun</option>
            <option value="0">Áo Khoác</option>
            </select>
        </td>
    </tr>
    <tr>
        <td>Chương Trình Khuyến Mãi:  </td>
        <td>
        <select name="loaikhuyenmai">
            <option value="1">dau nan</option>
            <option value="2">cuoi nam</option>
            <option value="3">Ngay le 2/9</option>
            <option value="4">ngay le 30/10</option>
        </select>
        </td>
    </tr>
    <tr>
            <td>Mô Tả:</td><td><textarea name="des" rows="5" cols="20"></textarea></td>
        </tr>
    <tr><td>Hình Ảnh: </td><td> <input type="file" name="file"><br></td></tr>    
    <tr><td></td><td><input type="submit" name="submit" value="Add"></td></tr>
</form>

